var openid = getQueryString("openid");
var upTime;
function customerFun () {
	$.get(
		  API_URL+'agentmanagement/findManagement?openid='+openid,
		  function(data){
		  	var myData = data.basedata;
		  	// 参与人数
		  	$('.per_num span').text(myData.prosum);
		  	// 转发人数
		  	$('.share_num span').text(myData.sharsum);

		  	// 前三名
		  	var agentObj = myData.agent_item;
		  	var itemStr = '';
		  	for(var i=0; i<agentObj.length; i++){

		  		if(agentObj[i].icon == null || agentObj[i].icon == ''){
					agentObj[i].icon = 'img/default.png';
				}
		  		itemStr += '<li>'+
							  '<img src=\"'+agentObj[i].icon+'\" alt="">'+
							  '<p class="label_num"></p>'+
							  '<p class="rank_num">'+agentObj[i].sum+'</p>'+
							  '<p class="rank_name">'+agentObj[i].name+'</p>'+
						  '</li>';
		  	}
		  	$(".rank_list").html(itemStr);

		  	//初始化获奖列表
		  	var utilObj = myData.pageutil.data;
		  	var detialStr = '';
		  	var status = '';
		  	for(var i=0; i<utilObj.length; i++){
		  		if(utilObj[i].icon == null || utilObj[i].icon == ''){
					utilObj[i].icon = 'img/default.png';
				}
				if(utilObj[i].status == null || utilObj[i].status=='') {
					status = '&nbsp;';
				}else if(utilObj[i].status == 1){
					status = '成功';
				}else if(utilObj[i].status == 0){
					status = '充值中';
				}else if(utilObj[i].status == 9){
					status = "失败";
				}
				var luckdraw = utilObj[i].luckdraw;
				if(luckdraw==null || luckdraw==''){
					luckdraw = '未抽奖'
				}else if(luckdraw==0){
					luckdraw = 'plus'
				}else{
					luckdraw = luckdraw + '元';
				}
				
				upTime = utilObj[i].create_time;

		  		detialStr += '<li class="list_items clear">'+
								'<ul>'+
									'<li class="icon"><img src=\"'+utilObj[i].icon+'\" alt=""></li>'+
									'<li class="time">'+new Date(utilObj[i].create_time).format("MM-dd")+'</li>'+
									'<li class="">'+luckdraw+'</li>'+
									'<li class="status">'+status+'</li>'+
									'<li class=""><a href="tel:'+utilObj[i].phone+'"><i class="tel_icon"></i></a></li>'+
								'</ul>'+
							'</li>';
		  	}
		  	$("#pullUp").before(detialStr);
		  });
};
//上拉加载
function ListFun() {
	var status = '成功';
	$.get(
		  API_URL+'agentmanagement/findcus?operation=up&createtime_time='+upTime+'&openid='+openid,
		  function(data){
		  	var myData = data.basedata.data;
		  	var listStr = '';
		  	
		  	for(var i=0; i<myData.length; i++){
				var status='';
				if(myData[i].icon == null || myData[i].icon == ''){
					myData[i].icon = 'img/default.png';
				}
		  		if(myData[i].status == null || myData[i].status=='') {
					status = '';
				}else if(myData[i].status == 1){
					status = '成功';
				}else if(myData[i].status == 0){
					status = '充值中';
				}else if(myData[i].status == 9){
					status = "失败";
				}
				var luckdraw = myData[i].luckdraw;
				if(luckdraw==null || luckdraw==''){
					luckdraw = '未抽奖'
				}else{
					luckdraw = luckdraw + '元';
				}
				
				upTime = myData[i].create_time;

		  		listStr += '<li class="list_items clear">'+
								'<ul>'+
									'<li class="icon"><img src=\"'+myData[i].icon+'\" alt=""></li>'+
									'<li class="time">'+new Date(myData[i].create_time).format("MM-dd")+'</li>'+
									'<li class="">'+luckdraw+'</li>'+
									'<li class="status">'+status+'</li>'+
									'<li class=""><a href="tel:'+myData[i].phone+'"><i class="tel_icon"></i></a></li>'+
								'</ul>'+
							'</li>';
		  	}
		  	if(listStr == ''){
				$('#pullUp').hide();
			}else{
				$('#pullUp').show();
				$('#thelist .list_items:last-child').after(listStr);
			}
		  });
}